//
//  HeartMonthAxisValueFormatter.swift
//  DaRings
//
//  Created by 尹琼 on 2023/2/18.
//

import UIKit
import Charts

open class HeartMonthAxisValueFormatter: NSObject, IAxisValueFormatter {
    
    public var axisValueArray : [String] = []
     
    public func stringForValue(_ value: Double, axis: AxisBase?) -> String {
        
        let index = Int(value)
        print(index)
        if index == 0 {
            return "1"
        }
        var str = "\(index)"
        
        var after = index - index%5 + 5
        let last = Int(Double(axisValueArray.last!) ?? 31)
        if after > last {
            after = last
        }
        if index < after {
            str = "\(after)"
        }
        
        if axisValueArray.contains(str) {
            return str
        }
        
        return ""
        
    }

}
